import React, {Component} from 'react'
import {Card, Button, Form, Input, Select, Tree, Transfer, Modal} from 'antd'
import axios from '../../axios/index'
import ETable from '../../components/ETable/index'
import menuConfig from '../../config/menuConfig'
import Utils from '../../utils/utils'
const FormItem = Form.Item
const Option = Select.Option
const TreeNode = Tree.TreeNode
export default class Order extends Component{
    state = {}
    componentWillMount(){
        this.requestList()
    }

    requestList = () => {
        axios.ajax({
            url: '/role/list',
            data: {
                params: {}
            }
        }).then(res => {
            if(res.code == 0){
                let list = res.result.item_list.map((item, index) => {
                    item.key = index
                    return item
                })
                this.setState({
                    list
                })
            }
        })
    }

    render() {
        const columns = [
            {
                title: '用户ID',
                dataIndex: 'id'
            },
            {
                title: '角色名称',
                dataIndex: 'role_name'
            },
            {
                title: '创建时间',
                dataIndex: 'create_time',
                render: Utils.formatTime
            },
            {
                title: '使用状态',
                dataIndex: 'status',
                render(status){
                    return status == 1 ? "启用" : "停用"
                }
            },
            {
                title: '授权时间',
                dataIndex: 'authorize_time',
                render: Utils.formatTime
            },
            {
                title: '授权人',
                dataIndex: 'authorize_user_name',
            }
        ]
        return (
            <div>
                <Card>
                    <Button type="primary" onClick={this.handleRole}>创建角色</Button>
                    <Button type="primary" onClick={this.handlePermission}>设置权限</Button>
                    <Button type="primary" onClick={this.handleUserAuth}>用户授权</Button>
                </Card>
                <div className="content-wrap">
                    <ETable
                        updateSelectedItem={Utils.updateSelectedItem.bind(this)}
                        selectedRowKeys={this.state.selectedRowKeys}
                        dataSource={this.state.list}
                        columns={columns} />
                </div>
            </div>
        )
    }
}



